package com.catena.core;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * Created by hx-pc on 16-2-26.
 * 基础的节点参数,以后所有的参数都要继承这个接口
 */
public class NodeParameter {

    private int statusCode = 200;
    private int stepJumpIndex = 0;
    private Object data;
    private Map<String, Long> runStatusMap = new ConcurrentSkipListMap<>();
    @JsonIgnore
    private Map<String, Object> otherParam = new ConcurrentSkipListMap<>();
    @JsonIgnore
    private HttpServletResponse servletResponse;
    @JsonIgnore
    private HttpServletRequest servletRequest;

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public HttpServletResponse acceptServletResponse() {
        return servletResponse;
    }

    public void buildServletResponse(HttpServletResponse servletResponse) {
        this.servletResponse = servletResponse;
    }

    public HttpServletRequest acceptServletRequest() {
        return servletRequest;
    }

    public void buildServletRequest(HttpServletRequest servletRequest) {
        this.servletRequest = servletRequest;
    }

    public Map<String, Object> getOtherParam() {
        return otherParam;
    }

    public void setOtherParam(Map<String, Object> otherParam) {
        this.otherParam = otherParam;
    }

    public Map<String, Long> getRunStatusMap() {
        return runStatusMap;
    }

    public Map<String, Object> addOtherParam(String key, Object value) {
        otherParam.put(key, value);
        return otherParam;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public Map<String, Object> addAllOtherParam(Map map) {
        otherParam.putAll(map);
        return otherParam;
    }

    public void buildStepJumpIndex(int stepJumpIndex) {
        this.stepJumpIndex = stepJumpIndex;
    }

    public int acceptStepJumpIndex() {
        return stepJumpIndex;
    }

    public Map<String, Long> addRunStatusMap(String key, Long value) {
        runStatusMap.put(key, value);
        return runStatusMap;
    }

}
